<template>
  <a-modal
    :title="title"
    :width="1300"
    :visible="visible"
    :closable="true"
    :footer="null"
    @close="close"
    @cancel="handleCancel">
     <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :pagination="false"
        :dataSource="dataSource"
        :loading="loading"
        :scroll="{ x: 'calc(500px + 50%)' }">
          <div id="1234" slot="status" slot-scope="status"  >
            <a-tag v-if="status==1" color="orange">未发布</a-tag>
            <a-tag v-if="status==2" color="green">已发布</a-tag>
            <a-tag v-if="status==3" color="grey">已下架</a-tag>
          </div>
        <span slot="isTop" slot-scope="isTop">
            {{
                isTop==1 ? "是" : "否"
            }}
        </span>freeDrawBeginTime
        <span slot="validTime" slot-scope="text,recode">
          {{recode.validBeginTime}} 至 {{recode.validEndTime}}
        </span>

        <span slot="freeDrawTime" slot-scope="text,recode">
          {{recode.freeDrawBeginTime}} 至 {{recode.freeDrawEndTime}}
        </span>

        <span slot="couponNum" slot-scope="text,recode"> 
          {{recode.stockNum}} / {{recode.receiveNum}}
        </span>
        <img  style="width:60px;heigth:60px" slot="pic" slot-scope="pic" :src="getImgUrl(pic)" />
      </a-table>
  </a-modal>
</template>

<script>


  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  export default {
    name: 'AdhCouponListModal',
     mixins:[JeecgListMixin],
     
    data() {
      return {
        title:'商家优惠券列表',
        width:800,
        visible: false,
        disableSubmit: true,
        url: {
          list: "/adh/coupon/list",
        },
        queryParam: {merchId:''},
         href:window._CONFIG['domianURL']+"/sys/common/static/",
        columns: [
            {
                title:"优惠券名称",
                align:"center",
                width: 120,
                dataIndex:"couponType",
                customRender:function (text,row) {
                  if(text=="1"){
                    return "折扣券";
                  }else if(text=="2"){
                    return "代金券";
                  }else if(text=="3"){
                    return "展示券";
                  }
                }
            },
            {
                title:"优惠券名称",
                align:"center",
                dataIndex:"couponName",
            },
            {
                title:"有效期",
                align:"center",
                width: 200,
                dataIndex:"validBeginTime",
                scopedSlots: { customRender: 'validTime' },
            },
            {
                title:"免费领取时段",
                align:"center",
                width: 200,
                dataIndex:"freeDrawBeginTime",
                scopedSlots: { customRender: 'freeDrawTime' },
            },
            // {
            //     title:"提前购买价格",
            //     align:"center",
            //     width: 110,
            //     dataIndex:"advancePurchasePrice"
            // },
            {
                title:"总量/已领取",
                align:"center",
                width: 120,
                dataIndex:"stockNum",
                scopedSlots:{customRender:"couponNum"}
            },
            {
                title:"每人最大可领取数量",
                align:"center",
                width: 160,
                dataIndex:"useLimit"
            },
            {
                title:"是否首推",
                align:"center",
                width: 100,
                dataIndex:"ifTop",
                scopedSlots:{customRender:"isTop"}
            },
            {
                title:"发布状态",
                align:"center",
                width: 130,
                dataIndex:"couponStatus",
                scopedSlots:{customRender:"status"},
                fixed: 'right',
            } 
        ],
      }
    },
    methods:{
      close () {
        this.$emit('close');
        this.visible = false;
      },
      showModel:function(record){
        this.queryParam.merchId = record.id
        this.searchQuery();
        this.visible = true
      },
      handleCancel () {
        this.close()
      },
      getImgUrl(picUrl){
        return this.href + picUrl;
      },
    }
  }
</script>

<style scoped>
</style>